#pragma once
#include <cassert>

namespace Pdf
{
	template<class T> 
	class SmartPtr
	{
	private:
		typedef SmartPtr ThisType;

	public:
		typedef T   ElementType;
		typedef T*  ThisType::*UnspecifiedBoolType;

		            SmartPtr();
		            SmartPtr(T *p, bool addref = true);
		            SmartPtr(const SmartPtr &rhs);
		           ~SmartPtr();

		template<class U>
		SmartPtr(const SmartPtr<U> &rhs);

		SmartPtr&   operator= (const SmartPtr &rhs);
		SmartPtr&   operator= (T *rhs);
		T&          operator* () const;
		T*          operator->() const;
		bool        operator! () const throw();

		template<class U> 
		SmartPtr&   operator= (const SmartPtr<U> &rhs);

		void        reset();
		void        reset(T *rhs);
		T*		    get() const;
		void        swap(SmartPtr &rhs);

		operator UnspecifiedBoolType() const throw();

	private:
		T* px;
	};
}

#include "object_ptr.inl"